[Mini-OS] Optimize get_current()
authorKeir Fraser <keir.fraser@citrix.com>
Fri, 23 Nov 2007 16:23:03 +0000 (16:23 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Fri, 23 Nov 2007 16:23:03 +0000 (16:23 +0000)
Let gcc perform the computation with SP itself, leading to yet better
code.

Signed-off-by: Samuel Thibault <samuel.thibault@citrix.com>
extras/mini-os/include/x86/arch_sched.h

index 6bc47f89d36e954d88539d2327c9e4e9439e7046..7bf0036fac54ee5fab55597830dc25222730fd70 100644 (file)
@@ -7,10 +7,11 @@ static inline struct thread* get_current(void)
 {
     struct thread **current;
 #ifdef __i386__    
-    __asm__("andl %%esp,%0; ":"=r" (current) : "0" (~8191UL));
+    register unsigned long sp asm("esp");
 #else
-    __asm__("andq %%rsp,%0; ":"=r" (current) : "0" (~8191UL));
+    register unsigned long sp asm("rsp");
 #endif 
+    current = (void *)(sp & ~8191UL);
     return *current;
 }